package org.orange.feign.simulate.openfeign.controller;


import org.orange.feign.simulate.openfeign.service.TestFeignClient;
import org.orange.feign.simulate.openfeign.service.UserFeignClient;
import org.orange.feign.simulate.feign.common.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/custom/feign/user")
public class UserFeignController {

    @Autowired
    private TestFeignClient testClient;

    @Autowired
    private UserFeignClient userFeignClient;

    @RequestMapping("/user/{id}")
    public ResponseEntity<User> getPaymentById(@PathVariable("id") Integer id) {
        return new ResponseEntity(userFeignClient.getUserById(id), HttpStatus.OK);
    }

    @RequestMapping("/user/info/{id}")
    public ResponseEntity<User> getPaymentInfo(@PathVariable("id") Integer id) {
        return new ResponseEntity(userFeignClient.getUserInfo(id), HttpStatus.OK);
    }


}
